package com.kecheng.action;

import java.util.List;

import com.kecheng.dao.YunfeiDao;
import com.kecheng.pojo.Yunfei;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.AllowedMethods;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
@Action(value = "cart", results = {
		@Result(name = "all", location = "/admin/product/yunfei.jsp"),
})
@AllowedMethods(value = {("regex:.*")})
public class YunfeiAction {

	private Yunfei yunfei;
	@Autowired
	private YunfeiDao yunfeiDao;
	private List<Yunfei> yunfeis;
	private String msg;

	
	public String province(){
		try {
			yunfeis = yunfeiDao.find();
		} catch (Exception e) {
			msg="查询失败";
			e.printStackTrace();
		}
		return "province";
	}
	
	/*-----------------------------------*/
	
	public String findall() {
		yunfeis = yunfeiDao.find();
		return "all";
	}

	public String update() {
		Yunfei yunfei1 = yunfeiDao.findbyid(yunfei.getId());
		yunfei.setName(yunfei1.getName());
		yunfeiDao.update(yunfei);
		return findall();
	}

	public String piliang() {
		yunfeis = yunfeiDao.find();
		for (int i = 0; i < yunfeis.size(); i++) {
			Yunfei yunfei1 = yunfeis.get(i);

			yunfei1.setOne(yunfei.getOne());

			yunfei1.setTwo(yunfei.getTwo());

			yunfeiDao.update(yunfei1);

		}
		return findall();
	}

	public Yunfei getYunfei() {
		return yunfei;
	}

	public void setYunfei(Yunfei yunfei) {
		this.yunfei = yunfei;
	}

	public List<Yunfei> getYunfeis() {
		return yunfeis;
	}

	public void setYunfeis(List<Yunfei> yunfeis) {
		this.yunfeis = yunfeis;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

}
